package com.top.mall.jetpack.ma

import com.module.lemlin.http.HttpResponseData
import com.top.mall.app.BaseApplication
import com.top.mall.base.BaseManager
import com.top.mall.entity.*
import rxhttp.RxHttp
import rxhttp.await

class MineManager : BaseManager() {

    /**
     * 首页数据
     * */
    suspend fun submitInvoiceVoidTax(
        type: Int,
        tax_code: String,
        company_name: String,
        start_time: String,
        end_time: String,
        void_business_tax_img: String
    ): HttpResponseData =
        RxHttp.get("/api/invoice/submitInvoiceVoidTax")
            .add("type", type)
            .add("tax_code", tax_code)
            .add("company_name", company_name)
            .add("start_time", start_time)
            .add("end_time", end_time)
            .add("void_business_tax_img", void_business_tax_img)
            .await()


    suspend fun addressList(): AddressResponse =
        RxHttp.get("/api/user/addressList")
            .await()

    suspend fun leaderList(): LeaderResponse =
        RxHttp.get("/api/user/recipientList")
            .await()

    suspend fun saveAddress(
        id: Int? = null,
        province: Int,
        city: Int,
        district: Int,
        address: String, is_default: Int
    ): HttpResponseData {
        val http = RxHttp.get("/api/user/saveAddress")
            .add("province", province)
            .add("city", city)
            .add("district", district)
            .add("address", address)
            .add("is_default", is_default)
        if (id != null) {
            http.add("id", id)
        }
        return http.await()
    }

    suspend fun saveLeader(
        id: Int? = null,
        mobile: String,
        surname: String,
        user_name: String,
        id_card: String,
        birthday: String,
        is_default: Int
    ): HttpResponseData {
        val http = RxHttp.get("/api/user/saveRecipient")
            .add("mobile", mobile)
            .add("surname", surname)
            .add("user_name", user_name)
            .add("id_card", id_card)
            .add("birthday", birthday)
            .add("is_default", is_default)
        if (id != null) {
            http.add("id", id)
        }
        return http.await()
    }
}